
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UwinEducation.Domain.IRepositories
{

    /// <summary>
    /// 通用仓储接口
    /// </summary>
    /// <typeparam name="TEntity">实体类型</typeparam>
    /// <typeparam name="TKey">主键类型</typeparam>
    public interface IRepository<TEntity, TKey> where TEntity : class
    {
        /// <summary>
        /// 获取所有实体
        /// </summary>
        Task<IEnumerable<TEntity>> GetAllAsync();

        /// <summary>
        /// 根据ID获取实体
        /// </summary>
        Task<TEntity> GetByIdAsync(TKey id);

        /// <summary>
        /// 添加实体
        /// </summary>
        Task<TEntity> AddAsync(TEntity entity);

        /// <summary>
        /// 批量添加实体
        /// </summary>
        Task<List<TEntity>> AddRangeAsync(List<TEntity> entities);

        /// <summary>
        /// 更新实体
        /// </summary>
        Task UpdateAsync(TEntity entity);

        /// <summary>
        /// 批量更新实体
        /// </summary>
        Task UpdateRangeAsync(List<TEntity> entities);

        /// <summary>
        /// 删除实体
        /// </summary>
        Task DeleteAsync(TKey id);

        /// <summary>
        /// 获取查询对象
        /// </summary>
        IQueryable<TEntity> Query();
    }
}